package cn.rumoss.io.network;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.util.Arrays;

/**
 * @ClassName UDPRecive
 * @Description //TODO
 * @Author HeCG
 * @Date 19-4-22 下午3:42
 */
public class UDPRecive {

    public static void main(String[] args) throws Exception {

        int port = 23333;
        DatagramPacket receivePacket = new DatagramPacket(new byte[1024],1024);
        DatagramSocket server = new DatagramSocket(port);
        int i = 65530;
        while (true){
            server.receive(receivePacket);
            byte[] recvByte = Arrays.copyOfRange(receivePacket.getData(),
                    0, receivePacket.getLength());
            System.out.println("收到： " + new String(recvByte));
        }


    }

}
